package com.itboye.jmsfhz.main;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.itboye.app.mian.activity.EnterPriseMessgeFragment;
import com.itboye.app.mian.activity.HeZuoChengGuoFragment;
import com.itboye.app.mian.activity.PersonnelFragment;
import com.itboye.app.mian.activity.PracticeBaseFragment;
import com.itboye.app.mian.activity.SiFangHeZuoFragment;
import com.itboye.core.object.BaseFragment;
import com.itboye.jmsfhz.R;
import com.itboye.jmsfhz.app.ui.roof.TodaySpecialOfferItemFragment;
import com.itboye.jmsfhz.widget.PagerSlidingTabStrip;

/***
 * 屋顶Fragment
 * 
 * @author dsawe
 * 
 */
public class RoofFragment extends BaseFragment {
	String[] titles = { "首页", "组织机构", "四方合作", "人才推荐", "实践基地", "合作成果",
			"企业信息" };
	ViewPager pager;
	PagerSlidingTabStrip tabs;
	private ImageView img_other;

	@Override
	public int initView() {
		
		return R.layout.fragment_roof;
	}

	public class MyAdapter extends FragmentStatePagerAdapter {
		String[] _titles;

		public MyAdapter(FragmentManager fm, String[] titles) {
			super(fm);
			_titles = titles;
		}

		@Override
		public CharSequence getPageTitle(int position) {
			return _titles[position];
		}

		@Override
		public int getCount() {
			return _titles.length;
		}

		@Override
		public Fragment getItem(int position) {
			Fragment bfrag2 = null;
			if (position == 0) {
				bfrag2 = new TodaySpecialOfferItemFragment();
			}else if(position==1){
				bfrag2=new ZuZhiJiGOuFragment();
			}else if (position==2) {
				bfrag2=new SiFangHeZuoFragment();
			} else if(position==3){
				bfrag2 = new PersonnelFragment();
			}else if(position==4){
				bfrag2=new PracticeBaseFragment();
			}else if(position==5){
				bfrag2 = new HeZuoChengGuoFragment();
			}else if(position==6){
				bfrag2=new EnterPriseMessgeFragment();
			}
			return bfrag2;
		}

		@Override
		public void destroyItem(ViewGroup container, int position, Object object) {
			
			// super.destroyItem(container, position, object);
		}

		@Override
		public void destroyItem(View container, int position, Object object) {
			
			// super.destroyItem(container, position, object);
		}
	}

	@Override
	public void onMyActivityCreated() {
		pager.setAdapter(new MyAdapter(getChildFragmentManager(), titles));
		tabs.setViewPager(pager);

	}
}
